<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- jsp文件头和头部 -->
<%@ include file="../../system/admin/top.jsp"%>
</head>
<body>

	<div class="container-fluid" id="main-container">

		<div id="page-content" class="clearfix">
			<div class="row-fluid">
				<!-- 检索  -->
				<form action="order/list.do" method="post" name="Form" id="Form">
					<table>
						<tr>
							<td><span class="input-icon"> <input
									autocomplete="off" id="nav-search-input" type="text"
									name="ORDERNO" value="${pd.ORDERNO}"
									placeholder="请在这里输入订单编号" /> <i id="nav-search-icon"
									class="icon-search"></i>
							</span></td>
							<td style="vertical-align:top;"><button
									class="btn btn-mini btn-light" onclick="search();" title="检索">
									<i id="nav-search-icon" class="icon-search"></i>
								</button> 

						</tr>
					</table>
					<!-- 检索  -->

					<!-- 表格部份 -->
					<table id="table_report"
						class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th class="center"><label><input type="checkbox"
										id="zcheckbox" /><span class="lbl"></span></label></th>
								<th class="center">序号</th>
								<th class="center">订单编号</th>
								<th class="center">订单金额</th>
								<th class="center">订货数量</th>
								<th class="center">订货日期</th>
								<th class="center">订单状态</th>
								<th class="center">商品列表</th>
								<th class="center">操作</th>
							</tr>
						</thead>
						<tbody>
							<!-- 开始循环 -->
							<c:choose>
								<c:when test="${not empty varList}">
									<c:if test="${QX.cha==1}">
										<c:forEach items="${varList}" var="var" varStatus="vs">
											<!-- 主体部份 -->
											<tr>
												<td class="center" style="width:30px"><label><input
														type="checkbox" name="ids" value="${var.ORDERID }" /><span
														class="lbl"></span></label></td>
												<td class='center' style="width: 30px;">${vs.index+1}</td>
												<td class="center" style="width:150px">${var.ORDERNO}</td>
												<td class="center" style="width:150px">${var.ORDERSUM}</td>
												<td class="center">${var.QUANTITY}</td>
												<td class="center">${var.ORDERDATE.toString().substring(0,10)}</td>
												<td class="center">${var.ORDERSTATE}</td>
												<td class="center">产品列表</td>

												<td style="width: 30px;" class="center">
													<div class='hidden-phone visible-desktop btn-group'>
														<c:if test="${QX.edit != 1 && QX.del != 1 }">
															<span
																class="label label-large label-grey arrowed-in-right arrowed-in"><i
																class="icon-lock" title="无权限"></i></span>
														</c:if>
														<div class="inline position-relative">
															<button class="btn btn-mini btn-info"
																data-toggle="dropdown">
																<i class="icon-cog icon-only"></i>
															</button>
															<ul
																class="dropdown-menu dropdown-icon-only dropdown-light pull-right dropdown-caret dropdown-close">
																<c:if test="${QX.edit == 1 }">
																	<li><a style="cursor:pointer;" title="编辑"
																		onclick="edit('${var.ORDERID}');"
																		class="tooltip-success" data-rel="tooltip" title=""
																		data-placement="left"><span class="green"><i
																				class="icon-edit"></i></span></a></li>
																</c:if>
																<c:if test="${QX.del == 1 }">
																	<li><a style="cursor:pointer;" title="删除"
																		onclick="del('${var.ORDERID}');" class="tooltip-error"
																		data-rel="tooltip" title="" data-placement="left"><span
																			class="red"><i class="icon-trash"></i></span> </a></li>
																</c:if>
															</ul>
														</div>
													</div>
												</td>
											</tr>
										</c:forEach>
									</c:if>
								</c:when>
							</c:choose>
						</tbody>
					</table>

					<!-- 新增和删除数据 -->
					<div class="page-header position-relative">
						<table style="width:100%;">
							<tr>
								<td style="vertical-align:top;"><c:if
										test="${QX.add == 1 }">
										<a class="btn btn-small btn-success" onclick="add();">新增</a>
									</c:if> <c:if test="${QX.del == 1 }">
										<a class="btn btn-small btn-danger"
											onclick="makeAll('确定要删除选中的数据吗?');" title="批量删除"><i
											class='icon-trash'></i></a>
									</c:if></td>
								<td style="vertical-align:top;"><div class="pagination"
										style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
							</tr>
						</table>
					</div>

				</form>

			</div>
		</div>

	</div>





	    <script src="static/js/bootstrap.min.js"></script>
		<script src="static/js/ace-elements.min.js"></script>
		<script src="static/js/ace.min.js"></script>

		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
		<!-- 下拉框 -->
		<script type="text/javascript"
			src="static/js/bootstrap-datepicker.min.js"></script>
		<!-- 日期框 -->
		<script type="text/javascript" src="static/js/bootbox.min.js"></script>
		<!-- 确认窗口 -->
		<!-- 引入 -->
		<script type="text/javascript" src="static/js/jquery.tips.js"></script>
		<!--提示框-->
	<!-- 返回顶部  -->
	<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse"> <i
		class="icon-double-angle-up icon-only"></i>
	</a>

	
	<script type="text/javascript">
	$(top.hangge());
	
	//检索
	function search(){
		top.jzts();
		$("#Form").submit();
	}
	
	//新增
	function add(){
		 top.jzts();
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="新增";
		 diag.URL = '<%=basePath%>order/goAdd.do';
		 diag.Width = 600;
		 diag.Height = 390;
		 diag.CancelEvent = function(){ //关闭事件
			 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				 if('${page.currentPage}' == '0'){
					 top.jzts();
					 setTimeout("self.location=self.location",100);
				 }else{
					 nextPage(${page.currentPage});
				 }
			}
			diag.close();
		 };
		 diag.show();
	}
	//删除
	function del(Id){
		bootbox.confirm("确定要删除吗?", function(result) {
			if(result) {
				top.jzts();
				var url = "<%=basePath%>order/delete.do?ORDERID="+Id;
				$.get(url,function(data){
					nextPage(${page.currentPage});
				});
			}
		});
	}
	//修改
	function edit(Id){
		
		 top.jzts();
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="编辑";
		 diag.URL = '<%=basePath%>order/goEdit.do?ORDERID='+Id;
		 diag.Width = 600;
		 diag.Height = 390;
		 diag.CancelEvent = function(){ //关闭事件
			 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				 nextPage(${page.currentPage});
			}
			diag.close();
		 };
		 diag.show();
	}
	
	//复选框
	$('table th input:checkbox').on('click' , function(){
		var that = this;
		$(this).closest('table').find('tr > td:first-child input:checkbox')
		.each(function(){
			this.checked = that.checked;
			$(this).closest('tr').toggleClass('selected');
		});
			
	});
	
	//批量操作
	function makeAll(msg){
		bootbox.confirm(msg, function(result) {
			if(result) {
				var str = '';
				for(var i=0;i < document.getElementsByName('ids').length;i++)
				{
					  if(document.getElementsByName('ids')[i].checked){
					  	if(str=='') str += document.getElementsByName('ids')[i].value;
					  	else str += ',' + document.getElementsByName('ids')[i].value;
					  }
				}
				if(str==''){
					bootbox.dialog("您没有选择任何内容!", 
						[
						  {
							"label" : "关闭",
							"class" : "btn-small btn-success",
							"callback": function() {
								//Example.show("great success");
								}
							}
						 ]
					);
					
					$("#zcheckbox").tips({
						side:3,
			            msg:'点这里全选',
			            bg:'#AE81FF',
			            time:8
			        });
					
					return;
				}else{
					
					
					if(msg == '确定要删除选中的数据吗?'){
						top.jzts();
						$.ajax({
							type: "POST",
							url: '<%=basePath%>order/deleteAll.do',
					    	data: {DATA_IDS:str},
							dataType:'json',
							//beforeSend: validateData,
							cache: false,
							success: function(data){
								 $.each(data.list, function(i, list){
										nextPage(${page.currentPage});
								 });
							}
						});
					}
				}
			}
		});
	}
	
	
	
	</script>
</body>
</html>

